package com.company.alibaba.test;


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Dispatch {

    public static class Point{
        int x;
        int y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Point[] points = new Point[n];
        for(int i = 0; i < n; i++){
            String line = sc.next();
            String[] arr = line.split(",");
            Point p = new Point(Integer.parseInt(arr[0]), Integer.parseInt(arr[1]));
            points[i] = p;
        }
        Point curr = new Point(0, 0);
        List<Integer> dists = new ArrayList<>();
        count(points, curr, new ArrayList<Point>(), 0, dists);
        int min = 999;
        for(int item: dists){
            if(item < min){
                min = item;
            }
        }
        System.out.println(min);
    }

    public static void count(Point[] points, Point curr, List<Point> passeds, int currDist, List<Integer> dists){
        boolean flag = true;
        for(Point item: points){
            if(!passeds.contains(item)){
                flag = false;
                break;
            }
        }
        if(flag){
            dists.add(currDist);
            return;
        }else{
            for(Point item: points){
                if(!passeds.contains(item)){
                    int dist = Math.abs(curr.x - item.x) + Math.abs(curr.y - item.y);
                    int newDist = currDist + dist;
                    List<Point> newPasseds = new ArrayList<>(passeds);
                    newPasseds.add(item);
                    count(points, item, newPasseds, newDist, dists);
                }
            }
        }
    }

}
